<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>餐厅区域打印</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  {include file="public/css"/}
	<link rel="stylesheet" href="__STATIC__/admin/poster/jquery.contextMenu.css"/>
	<style>
		#poster{width:344px;height:600px;border:0px solid #ccc;position:relative;overflow:hidden}
		#poster::-webkit-scrollbar { /*滚动条整体样式*/
			width: 2px;     /*高宽分别对应横竖滚动条的尺寸*/
			height: 0px;
		}
		#poster::-webkit-scrollbar-thumb { /*滚动条里面小方块*/
			border-radius: 1px;
			-webkit-box-shadow: inset 0 0 1px rgba(0,0,0,0.5);
			background: rgba(0,0,0,0.5);
		}
		#poster::-webkit-scrollbar-track { /*滚动条里面轨道*/
			-webkit-box-shadow: inset 0 0 0px rgba(0,0,0,0.2);
			border-radius: 0;
			background: rgba(0,0,0,0);
		}
		#poster .bg{position:absolute;width:100%;z-index:0;}
		#poster .drag[type=img] img,#poster .drag[type=thumb] img {width:100%;height:100%; }

		#poster .drag {position: absolute; width:80px;height:80px; border:1px solid rgba(0,0,0,0.5); }

		#poster .drag[type=nickname]{ width:80px;height:40px; font-size:14px; line-height:14px; font-family: 黑体;}
		#poster .drag[type=text]{ width:auto;height:auto; font-size:14px; line-height:14px; font-family: 黑体;}
		#poster .drag[type=textarea]{overflow:hidden;font-size:14px; line-height:14px; font-family: 黑体;}
		#poster .drag[type=pro_img]{ background:#eee;overflow:hidden}
		#poster .drag img { position:absolute;z-index:0;width:100%; }
		#poster .drag .shadow {width:100%;height:100%}

		#poster .rRightDown,.rLeftDown,.rLeftUp,.rRightUp,.rRight,.rLeft,.rUp,.rDown{position:absolute;width:7px;height:7px;z-index:1;font-size:0;}
		#poster .rRightDown,.rLeftDown,.rLeftUp,.rRightUp,.rRight,.rLeft,.rUp,.rDown{background:rgba(200,0,0,0.5);}
		.rLeftDown,.rRightUp{ cursor:ne-resize;}
		.rRightDown,.rLeftUp{ cursor:nw-resize;}
		.rRight,.rLeft{ cursor:e-resize;}
		.rUp,.rDown{ cursor:n-resize;}
		.rLeftDown{ left:-4px;bottom:-4px;}
		.rRightUp{ right:-4px;top:-4px;}
		.rRightDown{ right:-4px;bottom:-4px;}
		.rRightDown{ background-color:#00F;}

		.rLeftUp{ left:-4px;top:-4px;}
		.rRight{ right:-4px;top:50%;margin-top:-4px;}
		.rLeft{ left:-4px;top:50%;margin-top:-4px;}
		.rUp{ top:-4px;left:50%;margin-left:-4px;}
		.rDown{ bottom:-4px;left:50%;margin-left:-4px;}
		.context-menu-layer { z-index:9999;}
		.context-menu-list { z-index:9999;}
		.layui-form-label{width: 115px !important;}
	</style>
</head>
<body>
  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-card layui-col-md12">
				<div class="layui-card-header">
					{if !$info['id']}<i class="fa fa-plus"></i> 添加区域{else}<i class="fa fa-pencil"></i> 编辑区域{/if}
					<i class="layui-icon layui-icon-close" style="font-size:18px;font-weight:bold;cursor:pointer" onclick="closeself()"></i>
				</div>
				<div class="layui-card-body" pad15>
					<div class="layui-form form-label-w6">
						<input type="hidden" name="info[id]" value="{$info.id}"/>
						<div class="layui-form-item">
							<label class="layui-form-label">名称：</label>
							<div class="layui-input-inline" style="width:200px">
								<input type="text" name="info[name]" lay-verify="required" lay-verType="tips" class="layui-input" value="{$info.name}">
							</div>
						</div>

						<div class="layui-form-item">
							<label class="layui-form-label">打印类型：</label>
							<div class="layui-input-inline">
								<input type="radio" name="info[print_template_type]" value="1" title="一菜一单" {if $info['id'] && $info['print_template_type']==1}checked{/if} lay-filter="print_template_type">
								<input type="radio" name="info[print_template_type]" value="0" title="普通打印" {if !$info['id'] || $info['print_template_type']==0}checked{/if} lay-filter="print_template_type">
							</div>
							<div class="layui-form-mid layui-word-aux">厨房等出菜区域建议选择一菜一单，吧台选择普通打印，普通打印的区域会全部打印</div>
						</div>
						<div class="layui-form-item" id="print_zt_type_div">
							<label class="layui-form-label">选择打印机：</label>
							<div class="layui-input-inline" style="width:500px">
								{php} $storeids = explode(',',$info['print_ids']);{/php}
								{foreach $printArr as $k=>$v}
								<input type="checkbox" name="info[print_ids][]" value="{$k}" title="{$v}" lay-skin="primary" {if in_array($k,$storeids)}checked{/if}>
								{/foreach}
							</div>
						</div>
						{if getcustom('restaurant_tag_num_print_type')}
						<div class="layui-form-item" id="print_type"  {if $info['tag_print_status'] ==1}style="display:none" {/if}>
							<label class="layui-form-label">同规格打印类型：</label>
							<div class="layui-input-inline" style="width: 290px">
								<input type="radio" name="info[num_print_type]" value="0" title="一个数量一张" {if !$info['id'] || $info['num_print_type']==0}checked{/if} >
								<input type="radio" name="info[num_print_type]" value="1" title="数量合并" {if $info['id'] && $info['num_print_type']==1}checked{/if} >
							</div>
							<div class="layui-form-mid layui-word-aux">数量合并：同规格多数量，一张标签打印多数量，例如：购买烧烤10串，打印一张标签纸，数量是 * 10；一个数量一张：同规格多数量，一个数量一张，例如：购买2杯奶茶，打印2张标签纸，数量分别是 * 1</div>
						</div>
						{/if}
						{if getcustom('restaurant_tag_wifiprint')}
						<div {if $info['print_template_type'] ==0}style="display:none"{/if} id="ycyd">

							<div class="layui-form-item">
								<label class="layui-form-label">开启标签打印：</label>
								<div class="layui-input-inline">
									<input type="radio" name="info[tag_print_status]" value="1" title="开启" {if $info['id'] && $info['tag_print_status']==1}checked{/if} lay-filter="tag_print_status">
									<input type="radio" name="info[tag_print_status]" value="0" title="关闭" {if !$info['id'] || $info['tag_print_status']==0}checked{/if} lay-filter="tag_print_status">
								</div>
								<div class="layui-form-mid layui-word-aux">开启后，下方的标签设置生效</div>
							</div>
					
							<div id="tag_print_content" {if $info['tag_print_status'] ==0}style="display:none" {/if}>
								<div class="layui-form-item">
									<label class="layui-form-label">标签纸宽度：</label>
									<div class="layui-input-inline" >
										<input type="num" id="tag_width"   name="info[tag_width]" class="layui-input" value="{$info.tag_width?$info.tag_width:'60'}">
									</div>
									<div class="layui-form-mid layui-word-aux">单位mm</div>
									<div class=" layui-word-aux" style="margin-left:125px;clear: both">请与已选择的标签打印机的宽度一致</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">标签纸高度：</label>
									<div class="layui-input-inline" >
										<input type="num" id="tag_height" name="info[tag_height]" class="layui-input" value="{$info.tag_height?$info.tag_height:'60'}">
									</div>
									<div class="layui-form-mid layui-word-aux">单位mm</div>
									<div class=" layui-word-aux" style="margin-left:125px;clear: both">请与已选择的标签打印机的高度一致</div>
								</div>
								<div class="layui-form-item" id="tag_template">
									<label class="layui-form-label">标签打印模板：</label>
									<div class="layui-input-inline" style="width:300px" >
										<div id="poster"  style="background: #f1f1f1;height:240px;width: 240px;position: relative">
											{if !empty($tag_data)}
											{foreach $tag_data as $key=>$d}
												<div class="drag" type="{$d['type']}" index="{$key+1}" style="zindex:{$key+1};left:{$d['left']};top:{$d['top']};{if $d['type']!='text'}width:{$d['width']};height:{$d['height']}{/if}" src="{$d['src']}" size="{$d['size']}" w="{$d['w']}" h="{$d['h']}" color="{$d['color']}" content="{$d['content']}">
													{if $d['type']=='text'}
													<div class=text style="font-size:{$d['size']};line-height:{$d['size']};color:{$d['color']}">{$d['content']}</div>
													{elseif $d['type']=='textarea'}
													<div class=textarea style="font-size:{$d['size']};line-height:{$d['size']};color:{$d['color']}">{$d['content']}</div>
													{elseif $d['type']=='qrcode'}
														<img src="__STATIC__/admin/poster/qrmp.jpg" />
													{/if}
													{if $d['type'] !='qrcode'}
													<div class="rRightDown"> </div><div class="rLeftDown"> </div><div class="rRightUp"> </div><div class="rLeftUp"> </div><div class="rRight"> </div><div class="rLeft"> </div><div class="rUp"> </div><div class="rDown"></div>
													{/if}
												</div>	
											 {/foreach}
											 
											 {/if}
										</div>
									</div>
								
									
									<div class="layui-input-inline" style="width:500px">
										<div class="layui-form-item">
											<label class="layui-form-label">标签元素</label>
											<button class='layui-btn layui-btn-primary btn-com' type='button' data-type='text' style="margin-bottom:5px">文字</button>
		
											<button class='layui-btn layui-btn-primary btn-com' type='button' data-type='textarea' style="margin-bottom:5px">文本块</button>
											{if  getcustom('restaurant_take_food')}
											<button class='layui-btn layui-btn-primary btn-com' type='button' data-type='qrcode' style="margin-bottom:5px">取餐码</button>
											 {/if}
										</div>
										<div  id="textset">             <!--  id='textareaset'-->
											<div class="layui-form-item">
												<label class="layui-form-label">文字内容</label>
												<div class="layui-input-inline" style="width:190px">
													<input type="text" value="" id="textcontent" class="layui-input">
												</div>
												<div class="layui-form-mid layui-word-aux" style="clear:both;margin-left:130px;">[序号]、[商户名称]、[排队号]、[桌号名称]、[商品名称]、[商品单价]、[规格参数]、[订单号]、[备注]{if getcustom('restaurant_take_food')}、[取餐号]{/if}{if getcustom('restaurant_product_jialiao')}、[加料]{/if}{if getcustom('restaurant_cashdek_ordergoods_remark')}、[单品备注]{/if}{if getcustom('restaurant_product_package')}、[套餐名]{/if}会自动替换为当前商户的名称、排队号、桌号名称、商品名称、商品单价、规格参数、备注，[序号]为同一订单中的流水序号如：1/4。</div>
											</div>
											<input type="hidden" id="textsize" class="layui-input" value=""/>
											<div class="layui-form-item" >
											
												<label class="layui-form-label">宽度放大倍率</label>
												<div class="layui-input-inline">
													<input type="text" id="textw" class="layui-input" placeholder="文字宽度放大倍率1-10"/>
												</div>
												<div class="layui-form-mid" style="margin-left:10px;">倍</div>
										
											</div>
											<div class="layui-form-item" >
												<label class="layui-form-label">高度放大倍率</label>
												<div class="layui-input-inline">
													<input type="text" id="texth" class="layui-input" placeholder="文字宽度放大倍率1-10"/>
												</div>
												<div class="layui-form-mid" style="margin-left:10px;">倍</div>
		
											</div>
										</div>
										<div id='textareaset' style='display:none'>
											<input type="hidden" id="textareasize" class="layui-input" value=""/>
											<div class="layui-form-item">
												<label class="layui-form-label">文本内容</label>
												<div class="layui-input-inline" style="width:190px">
													<input type="text" value="" id="textareacontent" class="layui-input">
												</div>
												<div class="layui-form-mid layui-word-aux" style="clear:both;margin-left:110px;">[商户名称]、[商户电话]、[商城名称]会自动替换为当前商户的名称、电话 和 商城名称</div>
											</div>
											<div class="layui-form-item">
												<label class="layui-form-label">宽度放大倍率</label>
												<div class="layui-input-inline">
													<input type="text" id="textareaw" class="layui-input" placeholder="文字宽度放大倍率1-10"/>
												</div>
												<div class="layui-form-mid" style="margin-left:10px;">倍</div>
											</div>
											<div class="layui-form-item" >
												<label class="layui-form-label">高度放大倍率</label>
												<div class="layui-input-inline">
													<input type="text" id="textareah" class="layui-input" placeholder="文字宽度放大倍率1-10"/>
												</div>
												<div class="layui-form-mid" style="margin-left:10px;">倍</div>
		
											</div>
										</div>
									</div>
									<div class=" layui-word-aux" style="margin-left:125px;clear: both">模板和实际标签比例有一定差距，请进行多次调整</div>
								</div>
							</div>
						</div>	
						{/if}
						<div class="layui-form-item">
							<label class="layui-form-label">状态：</label>
							<div class="layui-input-inline">
								<input type="radio" name="info[status]" value="1" title="开启" {if !$info['id'] || $info['status']==1}checked{/if}>
								<input type="radio" name="info[status]" value="0" title="关闭" {if $info['id'] && $info['status']==0}checked{/if}>
							</div>
						</div>

						<div class="layui-form-item">
							<label class="layui-form-label"></label>
							<div class="layui-input-block">
								<button class="layui-btn layui-btn-danger" lay-submit lay-filter="formsubmit">提 交</button>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
  </div>
	{include file="public/js"/}
  <script src="__STATIC__/admin/js/jscolor.js"></script>
  <script language='javascript' src="__STATIC__/admin/poster/designer.js"></script>
  <script language='javascript' src="__STATIC__/admin/poster/jquery.contextMenu.js"></script>
	<script>
	layui.form.on('submit(formsubmit)', function(obj){
		{if getcustom('restaurant_tag_wifiprint')}
		var data = [];
		$('.drag').each(function(){
			var obj = $(this);
			var type = obj.attr('type');
			var left = obj.css('left'),top = obj.css('top');
			var d= { left:left,top:top,type:obj.attr('type'),width:obj.css('width'),height:obj.css('height')};
			if(type=='qrwx'|| type=='qrmp'|| type=='qrgz'|| type=='qrtoutiao'|| type=='qrbaidu' || type=='qralipay'){
				d.size = obj.attr('size');
			}else if(type=='qrcode'){
				d.size = obj.attr('qrsize');
			} else if(type=='img'){
				d.src = obj.attr('src');
			} else if(type=='text'){
				d.size = obj.attr('size');
				d.color = obj.attr('color');
				d.w = obj.attr('w');
				d.h = obj.attr('h');
				d.content = obj.attr('content');
			} else if(type=='textarea'){
				d.size = obj.attr('size');
				d.color = obj.attr('color');
				d.w = obj.attr('w');
				d.h = obj.attr('h');
				d.content = obj.attr('content');
			} else if(type=='pro_img'){
				d.showyy = obj.attr('showyy');
			} else if(type=='shadow'){
				d.shadow = obj.find('.shadow').attr('shadow');
			} else if(type=='head'){
				d.radius = obj.find('img').attr('radius');
			}
			data.push(d);
		});
		var tag_data = JSON.stringify(data);
		obj.field.tag_data = tag_data;
		{/if}
			console.log(obj.field);
		var field = obj.field
		//console.log(field);return;
		var index = layer.load();
		$.post("{:url('save')}",field,function(data){
			layer.close(index);
			dialog(data.msg,data.status);
			if(data.status == 1){
				setTimeout(function(){
					parent.layer.close(parent.layer.getFrameIndex(window.name));
					parent.tableIns.reload()
				},1000)
			}
		})
	})
  </script>
  <script>
	  {if getcustom('restaurant_tag_wifiprint')}
	  
	  layui.form.on('radio(tag_print_status)',function(data){
		  if(data.value == '1'){
			  $('#tag_print_content').show();
		  }else{
			  $('#tag_print_content').hide();
		  }
	  })
	  layui.form.on('radio(print_template_type)',function(data){
		  if(data.value == '1'){
			  $('#ycyd').show();
			  $('#print_type').show();
		  }else{
			  $('#ycyd').hide();
			  $('#print_type').hide();
		  }
	  })
	  function bindEvents(obj){
		  var index = obj.attr('index');
		  var type = obj.attr('type');
		  if(type!='text' && type!='qrcode'){
			  var rs = new Resize(obj, { Max: true, mxContainer: "#poster" });
			  rs.Set($(".rRightDown",obj), "right-down");
			  rs.Set($(".rLeftDown",obj), "left-down");
			  rs.Set($(".rRightUp",obj), "right-up");
			  rs.Set($(".rLeftUp",obj), "left-up");
			  rs.Set($(".rRight",obj), "right");
			  rs.Set($(".rLeft",obj), "left");
			  rs.Set($(".rUp",obj), "up");
			  rs.Set($(".rDown",obj), "down");
			  rs.Scale = false;
			  if(type=='head' || type=='qrwx' || type=='qrmp' || type=='qrgz' || type=='qrtoutiao'|| type=='qrbaidu' || type=='qralipay'){
				  rs.Scale = true;
			  }
		  }
		  new Drag(obj, { Limit: true, mxContainer: "#poster" });
		  $('.drag .remove').unbind('click').click(function(){
			  $(this).parent().remove();
		  });
		  $.contextMenu({
			  selector:'.drag[index=' + index + ']',
			  callback: function(key, options) {
				  var index = parseInt($(this).attr('zindex'));
				  if(key=='next'){
					  var nextdiv = $(this).next('.drag');
					  if(nextdiv.length>0 ){
						  nextdiv.insertBefore($(this));
					  }
				  } else if(key=='prev'){
					  var prevdiv = $(this).prev('.drag');
					  if(prevdiv.length>0 ){
						  $(this).insertBefore(prevdiv);
					  }
				  } else if(key=='last'){
					  var len = $('.drag').length;
					  if(index >=len-1){
						  return;
					  }
					  var last = $('#poster .drag:last');
					  if(last.length>0){
						  $(this).insertAfter(last);
					  }
				  }else if(key=='first'){
					  var index = $(this).index();
					  if(index<=1){
						  return;
					  }
					  var first = $('#poster .drag:first');
					  if(first.length>0){
						  $(this).insertBefore(first);
					  }
				  }else if(key=='delete'){
					  $(this).remove();
				  }
				  var n =1 ;
				  $('.drag').each(function(){
					  $(this).css("z-index",n);
					  n++;
				  })
			  },
			  items: {
				  "next": { name: "调整到上层"},
				  "prev": { name: "调整到下层"},
				  "last": { name: "调整到最顶层"},
				  "first": { name: "调整到最低层"},
				  "delete": { name: "删除元素"}
			  }
		  });
		  obj.unbind('click').click(function(){
			  bind($(this));
		  });
	  }
	  var imgsettimer = 0 ;
	  var nametimer = 0;
	  var bgtimer = 0 ;
	  function clearTimers(){
		  clearInterval(imgsettimer);
		  clearInterval(nametimer);
		  clearInterval(bgtimer);
	  }
	  function bind(obj){
		  var imgset = $('#imgset'),qrwxset = $('#qrwxset'),qrmpset = $('#qrmpset'),qrgzset = $('#qrgzset'),qralipayset = $('#qralipayset'),qrbaiduset = $('#qrbaiduset'),qrtoutiaoset = $('#qrtoutiaoset'),textset = $('#textset'),textareaset = $('#textareaset'),pro_imgset=$('#pro_imgset'),shadowset=$('#shadowset'),headset=$('#headset'),qrcodeset = $('#qrcodeset');
		  imgset.hide(),qrwxset.hide(),qrmpset.hide(),qrgzset.hide(),textset.hide(),textareaset.hide(),pro_imgset.hide(),shadowset.hide(),headset.hide(),qrcodeset.hide();
		  clearTimers();
		  var type = obj.attr('type');
		  if(type=='img'){
			  imgset.show();
			  var src = obj.attr('src');
			  var input = imgset.find('input');
			  var img = imgset.find('img');
			  if(typeof(src)!='undefined' && src!=''){
				  input.val(src);
				  img.attr('src',src);
			  }
			  imgsettimer = setInterval(function(){
				  if(input.val()!=src && input.val()!=''){
					  var url = input.val();
					  obj.attr('src',input.val()).find('img').attr('src',url);
				  }
			  },10);
		  } else if(type=='qrcode'){
			  qrcodeset.show();
		  } else if(type=='pro_img'){
			  pro_imgset.show();
			  var showyy = obj.attr('showyy') || "1";
			  var sel = pro_imgset.find('#pro_imgshowyy');
			  sel.val(showyy);
			  sel.unbind('change').change(function(){
				  obj.attr('showyy',sel.val())
			  });
		  }  else if(type=='text'){
			  textset.show();
			  var content = obj.attr('content') || "[商户名称]";
			  var color = obj.attr('color') || "#000";
			  var size = obj.attr('size') || "12";
			  var w = obj.attr('w') || 1;
			  var h = obj.attr('h') || 1;
			  var textcontent = textset.find('#textcontent');
			  var textcolor = textset.find('#textcolor');
			  var textsize = textset.find('#textsize');
			  var textw = textset.find('#textw');
			  var texth = textset.find('#texth');
			  var picker = textset.find('.sp-preview-inner');
			  textcontent.val(content);
			  textcolor.val(color);
			  textsize.val(size.replace("px",""));
			  textw.val(w);
			  texth.val(h);
			  picker.find('.text').text( content );
			  picker.css( { 'background-color':color,'font-size':size});
			  initcolorpicker();
		
			  nametimer = setInterval(function(){
				  obj.attr('content',textcontent.val()).find('.text').text(textcontent.val());
				  obj.attr('color',textcolor.val()).find('.text').css('color',textcolor.val());
				  obj.attr('w',textw.val()).find('.text').css({'font-size':12*textw.val()  +"px",'line-height':12*texth.val() +"px"});
				  obj.attr('h',texth.val()).find('.text').css({'font-size':12*textw.val()  +"px",'line-height':12*texth.val() +"px"});
				    obj.attr('size',12*textw.val() +"px").find('.text').css({'font-size':12*textw.val() +"px",'line-height':12*texth.val() +"px"});
			  },10);
		  } else if(type=='textarea'){
			  textareaset.show();
			  var content = obj.attr('content') || "文本内容";
			  var color = obj.attr('color') || "#000";
			  var size = obj.attr('size') || "12";
			  var w = obj.attr('w') || 1;
			  var h = obj.attr('h') || 1;
			  var textareacontent = textareaset.find('#textareacontent');
			  var textareacolor = textareaset.find('#textareacolor');
			  var textareasize = textareaset.find('#textareasize');
			  var textareaw = textareaset.find('#textareaw');
			  var textareah = textareaset.find('#textareah');
			  var picker = textareaset.find('.sp-preview-inner');
			  textareacontent.val(content);
			  textareacolor.val(color);
			  textareasize.val(size.replace("px",""));
			  textareaw.val(w);
			  textareah.val(h);
			  picker.find('.textarea').text( content );
			  picker.css( { 'background-color':color,'font-size':size});
			  initcolorpicker();
			  nametimer = setInterval(function(){
				  obj.attr('content',textareacontent.val()).find('.textarea').text(textareacontent.val());
				  obj.attr('color',textareacolor.val()).find('.textarea').css('color',textareacolor.val());
				  obj.attr('w',textareaw.val()).find('.text').css({'font-size':12*textareaw.val()  +"px",'line-height':textareasize.val()*textareah.val() +"px"});
				  obj.attr('h',textareah.val()).find('.text').css({'font-size':12*textareaw.val()  +"px",'line-height':textareasize.val()*textareah.val() +"px"});
				  obj.attr('size',12*textareaw.val() +"px").find('.textarea').css({'font-size':12*textareaw.val() +"px",'line-height':12*textareah.val() +"px"});
			  },10);
		  }else if(type=='shadow'){
			  shadowset.show();
			  var shadowcolorValue = obj.find('.shadow').attr('shadow') || "rgba(0,0,0,0.5)";
			  $('#shadowcolor').val(shadowcolorValue)
			  shadowcolor();
			  nametimer = setInterval(function(){
				  obj.find('.shadow').attr('shadow',$('#shadowcolor').val());
				  obj.find('.shadow').css('background',$('#shadowcolor').val());
			  },10);
		  }else if(type=='head'){
			  headset.show();
			  headsliderValue = obj.find('img').attr('radius') || 0;
			  headslider.setValue(headsliderValue);
			  nametimer = setInterval(function(){
				  obj.find('img').attr('radius',headsliderValue);
				  obj.find('img').css('border-radius',headsliderValue/2+'%');
			  },10);
		  }
	  }
	  $(function(){
	  		//设置模板的 宽高
		  var tag_width = $('#tag_width').val();
		  var tag_height = $('#tag_height').val();
		  $("#poster").width(tag_width * 5);
		  $("#poster").height(tag_height * 5);
		  
		  
		  $('.drag').each(function(){
			  bindEvents($(this));
		  })
		  $('.btn-com').click(function(){
			  $('#imgset').hide()
			  $('#qrwxset').hide()
			  $('#qrmpset').hide()
			  $('#qrgzset').hide()
			  $('#qrbaiudset').hide()
			  $('#qralipayset').hide()
			  $('#qrtoutiaoset').hide()
			  $('#textset').hide();
			  $('#textareaset').hide();
			  $('#qrcodeset').hide();
			  clearTimers();
			  if($('#poster img').length<=0){
				  //alert('请选择背景图片!');
				  //return;
			  }
			  var type = $(this).data('type');
			  var img = "";
			  if(type=='qrwx'){
				  img = '<img src="__STATIC__/admin/poster/qrwx.jpg" />';
			  }else if(type=='qrmp'){
				  img = '<img src="__STATIC__/admin/poster/qrmp.jpg" />';
			  }else if(type=='qrgz'){
				  img = '<img src="__STATIC__/admin/poster/qrmp.jpg" />';
			  }else if(type=='qrbaidu'){
				  img = '<img src="__STATIC__/admin/poster/qrwx.jpg" />';
			  }else if(type=='qralipay'){
				  img = '<img src="__STATIC__/admin/poster/qrwx.jpg" />';
			  }else if(type=='qrtoutiao'){
				  img = '<img src="__STATIC__/admin/poster/qrwx.jpg" />';
			  }else if(type=='head'){
				  img = '<img src="__STATIC__/admin/poster/default-avatar.png" />';
			  }else  if(type=='img'){
				  img = '<img src="__STATIC__/admin/poster/img.png" />';
			  }else if(type=='pro_img'){
				  img = '<img src="__STATIC__/admin/poster/product.jpg" />';
			  }else  if(type=='qrcode'){
				  img = '<img src="__STATIC__/admin/poster/qrmp.jpg" />';
			  }else if(type=='text'){
				  img = '<div class=text>[商户名称]</div>';
			  }else if(type=='textarea'){
				  img = '<div class=textarea>文本内容</div>';
			  }else if(type=='shadow'){
				  img = '<div class="shadow" shadow="rgba(0,0,0,0.5)" style="background:rgba(0,0,0,0.5)"></div>';
			  }
			  var index = $('#poster .drag').length+1;
			  
			  if(type !='qrcode'){
				  var obj = $('<div class="drag" type="' + type +'" index="' + index +'" style="z-index:' + index+'">' + img+'<div class="rRightDown"> </div><div class="rLeftDown"> </div><div class="rRightUp"> </div><div class="rLeftUp"> </div><div class="rRight"> </div><div class="rLeft"> </div><div class="rUp"> </div><div class="rDown"></div></div>');
			  } else{
				  var obj = $('<div class="drag" type="' + type +'" index="' + index +'" style="z-index:' + index+'">'+img+'</div>');
		  	  }

			  $('#poster').append(obj);
			  bindEvents(obj);
		  });
		  $('.drag').click(function(){
		  	
			  bind($(this));
		  })
		  
	  })
	  $('#tag_width').blur(function () {
		  var tag_width = $('#tag_width').val();
		  tag_width = tag_width?tag_width:'60';
		  $("#poster").width(tag_width * 5);
	  })
	  $('#tag_height').blur(function () {
		  var tag_height = $('#tag_height').val();
		  tag_height = tag_height?tag_height:'60';
		  $("#poster").height(tag_height * 5);
	  })
	  {/if}
  </script>
	{include file="public/copyright"/}
</body>
</html>